package com.yishan;


import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class JiraTest {

    public static void main(String[] args) throws Exception {

        //可关闭的httpClient客户端
        CloseableHttpClient httpClient = HttpClients.createDefault();
        //String urlStr = "https://jira-dev.nioint.com/rest/api/2/search?orderBy=updated&jql=project='Function%20Release'&fields=created,updated,summary,customfield_17603,customfield_18414";
        //String urlStr = "https://jira-dev.nioint.com/rest/api/2/issue/FR-90744?fields=created,updated,summary,customfield_17603,customfield_18414";
        String urlStr = "https://jira-dev.nioint.com/rest/api/2/search?jql=project=%27Function+Release%27+AND+%28updated%3E+%222022-05-24%22+and+updated%3C+%222022-06-23%22%29&fields=created,updated,summary,customfield_17603,customfield_18414&startAt=0&maxResults=100";
        HttpGet httpGet = new HttpGet(urlStr);

        httpGet.setHeader("Content-type", "application/json");
        httpGet.setHeader("Authorization", "Basic bml0cC5zeXN0ZW06YzVBdXRORWRiQlFF");
        CloseableHttpResponse response = httpClient.execute(httpGet);
        //获取响应结果
        HttpEntity entity = response.getEntity();
        //对 httpEntity 操作的工具类
        String s = EntityUtils.toString(entity, StandardCharsets.UTF_8);
        System.out.println(s);
        // 确保流关闭
        EntityUtils.consume(entity);
        httpClient.close();






        //byte[] code = ("yys" + ":" + "shan012321").getBytes();
        //System.out.println("Basic " + Base64.getEncoder().encodeToString(code));

        //String s = authority("nitp.system", "c5AutNEdbBQE");
        //String s = authority("yys", "shan012321");
        //System.out.println(s);


    }
}
